package logic

import (
	"context"
	"house_srv/house"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type RentAddLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewRentAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RentAddLogic {
	return &RentAddLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *RentAddLogic) RentAdd(req *types.RentAddRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	rents, err := l.svcCtx.HouseRpc.RentAdd(l.ctx, &house.RentAddRequest{
		UserId:  req.UserId,
		HouseId: req.HouseId,
		MindMan: req.MinMan,
		Tel:     req.Tel,
	})
	if err != nil {
		return &types.Response{
			Mes:  err.Error(),
			Code: 500,
			Data: nil,
		}, nil
	}
	return &types.Response{
		Mes:  "预约发布成功",
		Code: 200,
		Data: rents,
	}, nil
}
